from django.db import models
from utils.models import ModelBase
# from apps.users.models import Users

# Create your models here.
# # 测试数据
# class Test(ModelBase):
#     """
#     create test model
#     """
#     name = models.CharField(max_length=20,verbose_name="测试名字")
#     age = models.CharField(max_length=10,verbose_name="测试年龄")
#
#     class Meta:
#         ordering = ['-age']
#         db_table = "tb_test"
#         verbose_name = "测试数据"
#         verbose_name_plural = verbose_name
#
#     def __str__(self):
#         return self.name

#机房名称
class IdcN(ModelBase):
    """
    create idc name model
    """
    name = models.CharField(max_length=20,verbose_name="机房名称")

    class Meta:
        db_table = "tb_idcn"
        verbose_name = "机房名称"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

#房间编号
class DesCond(ModelBase):
    """"
    create dc name model
    """
    fname = models.CharField(max_length=200,verbose_name="服务内容")
    cunit = models.CharField(max_length=20, verbose_name="计数单位")
    btime = models.IntegerField(verbose_name="基数时间")
    etime = models.IntegerField(verbose_name="每台处理时间")


    class Meta:
        db_table = "tb_dc"
        verbose_name = "计算参数"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.fname




#资产信息
class Gd(ModelBase):
    """
    create gd property model
    """
    gname = models.CharField(max_length=200,verbose_name="工单号或邮件名称")
    gcount = models.IntegerField(verbose_name="工单量")
    hcount = models.IntegerField(verbose_name="耗时计算")
    cuser = models.CharField(max_length=20,verbose_name="处理人")
    zb = models.CharField(max_length=20,verbose_name="5*8和非5*8",null=True)
    jj = models.CharField(max_length=20, verbose_name="紧急和非紧急", null=True)
    bz = models.CharField(max_length=1000,verbose_name="备注",null=True)
    dc = models.ForeignKey(DesCond,verbose_name='计算参数',on_delete=models.CASCADE,null=True) # 外键
    idcn = models.ForeignKey(IdcN, verbose_name='计算参数', on_delete=models.CASCADE, null=True)  # 外键


    class Meta:
        db_table = "tb_gd"
        verbose_name = "资产信息"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.gname

